<template>
	<view class="box">
		<view class="search">
			<input type="text" maxlength="30" :placeholder="placeholder" @input="onChange" v-model="inputValue"
				style="width: 74%;"></input>
			<view class="inquire">
				<view style="display: flex; align-items: center;">
					<view style="margin-right: 20rpx;" v-show="showIcon" @click="valueClear">
						<u-icon name="close-circle-fill" color="#909399" size="20"></u-icon>
					</view>
					<u-icon name="search" color="#909399" size="20"></u-icon>
					<slot name="fit">
						<view @click="click">
							{{title}}
						</view>
					</slot>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				inputValue: "",
				showIcon: false,
			}
		},
		props:{
			placeholder:{
				default: '请输入要查询的内容'
			},
			title:{
				default:'查询'
			}
		},
		methods: {
			onChange(e) {
				if (this.inputValue == "") {
					this.show = false,
					this.showIcon = false
				} else {
					this.showIcon = true
				}
			
			},
			valueClear() {
				this.inputValue = "";
				this.show = false,
				this.showIcon = false,
				this.overlay = false
			},
			click(){
				this.$emit('click')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box{
		padding: 30rpx;
	.search {
		background-color: #f8f8f8;
		border-radius: 50rpx;
		margin-bottom: 2rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 30rpx;
		position: relative;
		z-index: 3;

		.inquire {
			font-size: 28rpx;
			color: #062c71;
			font-weight: bold;
		}
	}
}
</style>